<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--
  Created by IntelliJ IDEA.
  User: ${USER}
  Date: ${DATE}
  Time: ${TIME}
  To change this template use File | Settings | File Templates.
--%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" isELIgnored="false" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<!DOCTYPE html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0 ,minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <base href="<%= basePath %>"/>
    <title>结算页面</title>

    <link href="<%= basePath %>/static/business/AmazeUI-2.4.2/assets/css/amazeui.css" rel="stylesheet" type="text/css"/>
    <link href="<%= basePath %>/static/business/basic/css/demo.css" rel="stylesheet" type="text/css"/>
    <link href="<%= basePath %>/static/business/css/cartstyle.css" rel="stylesheet" type="text/css"/>
    <link href="<%= basePath %>/static/business/css/jsstyle.css" rel="stylesheet" type="text/css"/>

    <script type="text/javascript" src="<%= basePath %>/static/business/js/jquery-1.7.2.min.js"></script>
    <script type="text/javascript" src="<%= basePath %>/static/business/js/address.js"></script>
</head>

<body>

<!--顶部导航条 -->
<div class="hmtop">
    <jsp:include page="head.jsp"/>
</div>


<div class="clear"></div>
<div class="concent">
    <!--地址 -->
    <div class="paycont">
        <div class="address">
            <h3>确认收货地址 </h3>
            <div class="control">
                <div class="tc-btn createAddr theme-login am-btn am-btn-danger">使用新地址</div>
            </div>
            <div class="clear"></div>
            <ul id="address-list-ul">
                <c:forEach items="${consigneeVoList}" var="consignee" begin="0" end="5">
                    <div class="per-border"></div>
                    <li onclick="isDefaultAddr('${consignee.customerAddrId}')"
                        class="user-addresslist ${ consignee.isDefault == 1 ? 'defaultAddr' : ''}">
                        <div class="address-left">
                            <div class="user DefaultAddr">
								<span class="buy-address-detail">
									<span class="buy-user">${consignee.customerUsername} </span>
									<span class="buy-phone">${consignee.customerUserphone}</span>
								</span>
                            </div>
                            <div class="default-address DefaultAddr">
                                <span class="buy-line-title buy-line-title-type">收货地址：</span>
                                <span class="buy--address-detail">
									<span class="province">${consignee.province}</span>
									<span class="city">${consignee.city}</span>
									<span class="dist">${consignee.district}</span>
									<span class="street">${consignee.address}</span>
								</span>
                            </div>
                            <c:if test="${consignee.isDefault==1}">
                                <ins class="deftip">默认地址</ins>
                            </c:if>
                        </div>
                        <div class="address-right">
                            <c:if test="${consignee.isDefault==0}">
                                <a href="cntApi/consignee"><span
                                        class="am-icon-angle-right am-icon-lg"></span></a>
                            </c:if>
                            <c:if test="${consignee.isDefault==1}">
                                <span class="am-icon-angle-right am-icon-lg"></span>
                            </c:if>
                        </div>
                        <div class="clear"></div>
                            <%--                        <div class="new-addr-btn">--%>
                            <%--                            <a href="javascript:void(0)" onclick="openDialog('${consignee.customerAddrId}')"--%>
                            <%--                               id="example"><i--%>
                            <%--                                    class="am-icon-edit"></i>编辑</a>--%>
                            <%--                            <span class="new-addr-bar">|</span>--%>
                            <%--                            <a href="javascript:void(0)" onclick="delClick('${consignee.customerAddrId}')"><i--%>
                            <%--                                    class="am-icon-trash"></i>删除</a>--%>
                            <%--                        </div>--%>
                    </li>
                </c:forEach>
            </ul>
            <div class="clear"></div>
        </div>
        <!--物流 -->
        <div class="logistics">
            <h3>选择物流方式</h3>
            <ul class="op_express_delivery_hot">
                <li data-value="yuantong" class="OP_LOG_BTN  "><i class="c-gap-right"
                                                                  style="background-position:0px -468px"></i>圆通<span></span>
                </li>
                <li data-value="shentong" class="OP_LOG_BTN  "><i class="c-gap-right"
                                                                  style="background-position:0px -1008px"></i>申通<span></span>
                </li>
                <li data-value="yunda" class="OP_LOG_BTN  "><i class="c-gap-right"
                                                               style="background-position:0px -576px"></i>韵达<span></span>
                </li>
                <li data-value="zhongtong" class="OP_LOG_BTN op_express_delivery_hot_last "><i class="c-gap-right"
                                                                                               style="background-position:0px -324px"></i>中通<span></span>
                </li>
                <li data-value="shunfeng" class="OP_LOG_BTN  op_express_delivery_hot_bottom"><i class="c-gap-right"
                                                                                                style="background-position:0px -180px"></i>顺丰<span></span>
                </li>
            </ul>
        </div>
        <div class="clear"></div>

        <!--支付方式-->
        <div class="logistics">
            <h3>选择支付方式</h3>
            <ul class="pay-list">
                <li class="pay" data-value="银联"><img
                        src="<%= basePath %>/static/business/images/wangyin.jpg" alt=""/>银联<span></span></li>
                <li class="pay" data-value="微信"><img
                        src="<%= basePath %>/static/business/images/weizhifu.jpg"/>微信<span></span></li>
                <li class="pay" data-value="支付宝"><img
                        src="<%= basePath %>/static/business/images/zhifubao.jpg"/>支付宝<span></span>
                </li>
            </ul>
        </div>
        <div class="clear"></div>

        <!--订单 -->
        <div class="concent">
            <div id="payTable">
                <h3>确认订单信息</h3>
                <div class="cart-table-th">
                    <div class="wp">

                        <div class="th th-item">
                            <div class="td-inner">商品信息</div>
                        </div>
                        <div class="th th-price">
                            <div class="td-inner">单价</div>
                        </div>
                        <div class="th th-amount">
                            <div class="td-inner">数量</div>
                        </div>
                        <div class="th th-sum">
                            <div class="td-inner">金额</div>
                        </div>
                        <div class="th th-oplist">
                            <div class="td-inner">配送方式</div>
                        </div>

                    </div>
                </div>
                <div class="clear"></div>
                <c:forEach items="${buyGoodsList}" var="buyInfo">
                    <tr class="item-list">
                        <div class="bundle  bundle-last">
                            <div class="bundle-main">
                                <ul class="item-content clearfix">
                                    <div class="pay-phone">
                                        <li class="td td-item">
                                            <div class="item-pic">
                                                <a href="#" class="J_MakePoint">
                                                    <img src="<%= basePath %>/static/business/images/kouhong.jpg"
                                                         class="itempic J_ItemImg"></a>
                                            </div>
                                            <div class="item-info">
                                                <div class="item-basic-info">
                                                    <a href="#" class="item-title J_MakePoint"
                                                       data-point="tbcart.8.11">${buyInfo.orderDetail.goodsName}</a>
                                                </div>
                                            </div>
                                        </li>
                                        <li class="td td-info">
                                            <div class="item-props">
                                                <span class="sku-line">颜色：12#川南玛瑙</span>
                                                <span class="sku-line">包装：裸装</span>
                                            </div>
                                        </li>
                                        <li class="td td-price">
                                            <div class="item-price price-promo-promo">
                                                <div class="price-content">
                                                    <em class="J_Price price-now"
                                                        id="price_${buyInfo.orderDetail.goodsId}"> ${buyInfo.orderDetail.goodsPrice}</em>
                                                </div>
                                            </div>
                                        </li>
                                    </div>
                                    <li class="td td-amount">
                                        <div class="amount-wrapper ">
                                            <div class="item-amount ">
                                                <span class="phone-title">购买数量</span>
                                                <div class="sl">
                                                    <input type="hidden" name="goodsId"
                                                           value="${buyInfo.orderDetail.goodsId}"/>
                                                    <input type="hidden" id="orderId" value="${buyInfo.orderId}">
                                                    <input type="button"
                                                           id="minBtn_${buyInfo.orderDetail.goodsId}"
                                                           onclick="resetAmount1('${buyInfo.orderDetail.goodsId}', '-','${buyInfo.orderId}');"
                                                           value="-"/>
                                                    <input class="text_box" readonly
                                                           id="amount1_${buyInfo.orderDetail.goodsId}"
                                                           type="text"
                                                           value="${buyInfo.orderDetail.goodsCnt}" style="width:30px;"/>
                                                    <input type="button"
                                                           id="addBtn_${buyInfo.orderDetail.goodsId}"
                                                           onclick="resetAmount1('${buyInfo.orderDetail.goodsId}', '+','${buyInfo.orderId}');"
                                                           value="+"/>
                                                </div>
                                            </div>
                                        </div>
                                    </li>
                                    <li class="td td-sum">
                                        <div class="td-inner">
                                            <em tabindex="0" class="J_ItemSum number"
                                                id="pay_sum_${buyInfo.orderDetail.goodsId}">${buyInfo.orderDetail.goodsPrice*buyInfo.orderDetail.goodsCnt}</em>
                                        </div>
                                    </li>
                                    <li class="td td-oplist">
                                        <div class="td-inner">
                                            <span class="phone-title">配送方式</span>
                                            <div class="pay-logis">
                                                快递<b class="sys_item_freprice">10</b>元
                                            </div>
                                        </div>
                                    </li>

                                </ul>
                                <div class="clear"></div>

                            </div>
                        </div>
                    </tr>
                </c:forEach>

                <div class="clear"></div>
            </div>

        </div>


        <div class="clear"></div>
        <div class="pay-total">
            <!--留言-->
            <div class="order-extra">
                <div class="order-user-info">
                    <div id="holyshit257" class="memo">
                        <label>买家留言：</label>
                        <input type="text" title="选填,对本次交易的说明（建议填写已经和卖家达成一致的说明）" placeholder="选填,建议填写和卖家达成一致的说明"
                               class="memo-input J_MakePoint c2c-text-default memo-close">
                        <div class="msg hidden J-msg">
                            <p class="error">最多输入500个字符</p>
                        </div>
                    </div>
                </div>

            </div>
            <!--优惠券 -->
            <div class="buy-agio">
                <li class="td td-coupon">

                    <span class="coupon-title">优惠券</span>
                    <select data-am-selected>
                        <option value="a">
                            <div class="c-price">
                                <strong>￥8</strong>
                            </div>
                            <div class="c-limit">
                                【消费满95元可用】
                            </div>
                        </option>
                        <option value="b" selected>
                            <div class="c-price">
                                <strong>￥3</strong>
                            </div>
                            <div class="c-limit">
                                【无使用门槛】
                            </div>
                        </option>
                    </select>
                </li>

                <li class="td td-bonus">
                    <span class="bonus-title">红包</span>
                    <select data-am-selected>
                        <option value="a">
                            <div class="item-info">
                                ¥50.00<span>元</span>
                            </div>
                            <div class="item-remainderprice">
                                <span>还剩</span>10.40<span>元</span>
                            </div>
                        </option>
                        <option value="b" selected>
                            <div class="item-info">
                                ¥50.00<span>元</span>
                            </div>
                            <div class="item-remainderprice">
                                <span>还剩</span>50.00<span>元</span>
                            </div>
                        </option>
                    </select>

                </li>

            </div>
            <div class="clear"></div>
        </div>
        <!--含运费小计 -->
        <div class="buy-point-discharge">
            <p class="price g_price ">
                合计（含运费） <span>¥</span><em class="pay-sum" id="pay_money"></em>
            </p>
        </div>

        <!--信息 -->
        <div class="order-go clearfix">
            <div class="pay-confirm clearfix">
                <div class="box">
                    <div tabindex="0" id="holyshit267" class="realPay"><em class="t">实付款：</em>
                        <span class="price g_price ">
                        <span>¥</span><em class="style-large-bold-red " id="J_ActualFee"></em>
					</span>
                    </div>

                    <div id="holyshit268" class="pay-address">
                        <p class="buy-footer-address">
                            <span class="buy-line-title buy-line-title-type">寄送至：</span>
                            <c:forEach var="csg" items="${consigneeVoList}">
                                <c:if test="${csg.isDefault=='1'}">
                                    <c:set var="defaultCsg" value="${csg}"/>
                                    <span class="buy--address-detail">
								   <span class="province">${csg.province}</span>
												<span class="city">${csg.city}</span>
												<span class="dist">${csg.district}</span>
												<span class="street">${csg.address}</span>
												</span>
                                    </span>
                                </c:if>
                            </c:forEach>
                        </p>
                        <p class="buy-footer-address">
                            <span class="buy-line-title">收货人：</span>
                            <span class="buy-address-detail">
                                         <span class="buy-user">${defaultCsg.customerUsername} </span>
												<span class="buy-phone">${defaultCsg.customerUserphone}</span>
												</span>
                        </p>
                    </div>
                </div>

                <div id="holyshit269" class="submitOrder">
                    <div class="go-btn-wrap">
                        <a id="J_Go" onclick="unifiedOrder('${onlineUser.customerBalance}');" class="btn-go"
                           tabindex="0" title="点击此按钮，提交订单">提交订单</a>
                    </div>
                </div>
                <div class="clear"></div>
            </div>
        </div>
    </div>

    <div class="clear"></div>
</div>
</div>
<div class="footer">
    <div class="footer-hd">
        <p>
            <a href="#">恒望科技</a>
            <b>|</b>
            <a href="#">商城首页</a>
            <b>|</b>
            <a href="#">支付宝</a>
            <b>|</b>
            <a href="#">物流</a>
        </p>
    </div>
    <div class="footer-bd">
        <p>
            <a href="#">关于恒望</a>
            <a href="#">合作伙伴</a>
            <a href="#">联系我们</a>
            <a href="#">网站地图</a>
            <em>© 2015-2025 Hengwang.com 版权所有</em>
        </p>
    </div>
</div>
</div>
<div class="theme-popover-mask"></div>
<div class="theme-popover">

    <!--标题 -->
    <div class="am-cf am-padding">
        <div class="am-fl am-cf"><strong class="am-text-danger am-text-lg">新增地址</strong> / <small>Add address</small>
        </div>
    </div>
    <hr/>

    <div class="am-u-md-12">
        <form class="am-form am-form-horizontal">

            <div class="am-form-group">
                <label for="user-name" class="am-form-label">收货人</label>
                <div class="am-form-content">
                    <input type="text" id="user-name" placeholder="收货人">
                </div>
            </div>

            <div class="am-form-group">
                <label for="user-phone" class="am-form-label">手机号码</label>
                <div class="am-form-content">
                    <input id="user-phone" placeholder="手机号必填" type="text">
                </div>
            </div>

            <div class="am-form-group">
                <label for="user-address" class="am-form-label">所在地</label>
                <div class="am-form-content address">
                    <select id="province" data-am-selected>
                        <option value="福建省">福建省</option>
                        <option value="1">山东省</option>
                        <option value="山东省">湖北省</option>
                        <option value="江西省">江西省</option>
                    </select>
                    <select id="city" data-am-selected>
                        <option value="福州市">福州市</option>
                        <option value="泉州市">泉州市</option>
                        <option value="厦门市">厦门市</option>
                        <option value="漳州市">漳州市</option>
                        <option value="济南市">济南市</option>
                        <option value="青岛市">青岛市</option>
                        <option value="烟台市">烟台市</option>
                        <option value="淄博市">淄博市</option>
                        <option value="武汉市">武汉市</option>
                        <option value="襄阳市">襄阳市</option>
                    </select>
                    <select id="district" data-am-selected>
                        <option value="晋安区">晋安区</option>
                        <option value="闽侯区">闽侯区</option>
                        <option value="历下区">历下区</option>
                        <option value="历城区">历城区</option>
                    </select>
                </div>
            </div>

            <div class="am-form-group">
                <label for="user-intro" class="am-form-label">详细地址</label>
                <div class="am-form-content">
                    <textarea class="" rows="3" id="user-intro" placeholder="输入详细地址"></textarea>
                    <small>100字以内写出你的详细地址...</small>
                </div>
            </div>

            <div class="am-form-group theme-poptit">
                <div class="am-u-sm-9 am-u-sm-push-3">
                    <input class="am-btn am-btn-danger" type="button" onclick="saveAddress();" value="保存"/>
                    <div class="am-btn am-btn-danger close" id="cancel_btn">取消</div>
                </div>
            </div>
        </form>
    </div>

</div>

<div class="clear"></div>
<script>


    $(function () {
        $(".op_express_delivery_hot>li").click(function () {
            console.log($(this).attr('data-value'));
        });
        $(".pay-list>li").click(function () {
            console.log($(this).attr('data-value'));
        });
        account();
    })

    //提交订单
    function unifiedOrder(balance) {
        var goodsIdArr = '', amountArr = '', priceArr = '', totalPrice = 0;
        $("input[name='goodsId']").each(function () {
            var goodsId = $(this).val();
            var price = $("#price_" + goodsId).text();
            var amount = $("#amount1_" + goodsId).val();
            goodsIdArr += goodsId + ',';
            amountArr += amount + ',';
            priceArr += Number(price) + ',';
            totalPrice += Number(price) * Number(amount);
        });
        if (Number(balance) < totalPrice) {
            alert("余额不足请先充值！")
            return;
        }
        if (totalPrice <= 0) {
            alert("请先添加商品！！！");
            return;
        }
        window.location.href = "orderApi/unifiedOrder?orderMoney=" + totalPrice;
    }

    //加减数量
    function resetAmount1(goodsId, method, orderId) {
        var amount = $("#amount1_" + goodsId).val();
        if (method == "-" && amount >= 1) {
            //个数减0 删除
            if (amount == 1) {
                if (window.confirm("是否确认删除该订单？")) {
                    window.location.href = "orderApi/deleteOrder?orderId=" + orderId;
                }
                return;
            }
            $("#amount1_" + goodsId).val(Number(amount) - 1);
        } else if (method == "+") {
            $("#amount1_" + goodsId).val(Number(amount) + 1);
        }
        window.location.href = "orderApi/updateOrderCnt?orderId=" + orderId + "&amount=" + $("#amount1_" + goodsId).val();
        account();
        return;
    }


    //统计金额和数量
    function account() {
        var totalPrice = 0;
        $("input[name='goodsId']").each(function () {
            var goodsId = $(this).val();
            var price = $("#price_" + goodsId).text();
            var amount = $("#amount1_" + goodsId).val();
            var money = Number(price) * Number(amount);
            totalPrice += money;
            $("#pay_sum_" + goodsId).text(money);
        });
        $("#J_ActualFee").text(totalPrice);
        $("#pay_money").text(totalPrice);

    }

    //新增保存收货地址
    function saveAddress() {
        var customerUsername = $("#user-name").val();
        var customerUserphone = $("#user-phone").val();
        var province = $("#province").val();
        var city = $("#city").val();
        var district = $("#district").val();
        var address = $("#user-intro").val();
        window.location.href = "orderApi/addConsignee?customerUsername=" + customerUsername + "&customerUserphone=" + customerUserphone + "&province=" + province + "&city=" + city + "&district=" + district + "&address=" + address;
    }

    // 设为默认
    function isDefaultAddr(customerAddrId) {
        window.location.href = "orderApi/isDefaultAddr?customerAddrId=" + customerAddrId;
    }
</script>
</body>

</html>